Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: r/demo/foo20airdrop - Merkle Airdrop contract example #906

Open
wants to merge 21 commits into
base: master
Choose a base branch
from

Conversation

albttx
Copy link
Member

@albttx albttx commented Jun 16, 2023

Description

This PR bring an example for a merkle airdrop contract.

  • the package p/demo/airdrop
  • the realm r/demo/foo20airdrop

How it's works ?

A merkle airdrop contract works by saving off-chain the elements of the merkle tree. ONLY the Merkle root is saved on the realm.

To confirm an element is present, we just need to send to the contract a merkle proof.

@albttx albttx requested review from jaekwon, moul and a team as code owners June 16, 2023 13:00
@albttx albttx self-assigned this Jun 16, 2023
@albttx albttx marked this pull request as draft June 16, 2023 13:01
@github-actions github-actions bot added 📦 🤖 gnovm Issues or PRs gnovm related 🧾 package/realm Tag used for new Realms or Packages. labels Jun 16, 2023
@albttx
Copy link
Member Author

albttx commented Jun 16, 2023

waiting for: #893 and #895 to undraft

@albttx albttx force-pushed the r/foo20-airdrop branch 2 times, most recently from 2060eff to 2675ea9 Compare July 23, 2023 12:42
@github-actions github-actions bot removed the 📦 🤖 gnovm Issues or PRs gnovm related label Jul 23, 2023
@albttx albttx force-pushed the r/foo20-airdrop branch from 2675ea9 to 08a8ac6 Compare July 23, 2023 12:44
@albttx albttx changed the title r/demo/foo20airdrop - Merkle Airdrop contract example feat: r/demo/foo20airdrop - Merkle Airdrop contract example Jul 23, 2023
@albttx albttx force-pushed the r/foo20-airdrop branch from 08a8ac6 to 7c384db Compare July 23, 2023 12:53
@albttx albttx marked this pull request as ready for review July 26, 2023 15:18
type AirdropData struct {
Address std.Address
// TODO: use std.Coin
Amount uint64
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For better control and data integrity, keep the fields in the Airdrop struct unexported.

To maintain easy marshaling with the Bytes helper, consider this approach:

type Airdrop struct {
    data struct {
        Address std.Address
        Amount  uint64
    }
}

Copy link
Member

@zivkovicmilos zivkovicmilos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good 💯

Please see @moul's comments, otherwise we should be good to go

examples/gno.land/p/demo/airdrop/merkle-airdrop.gno Outdated Show resolved Hide resolved
examples/gno.land/p/demo/airdrop/merkle-airdrop_test.gno Outdated Show resolved Hide resolved
examples/gno.land/r/demo/foo20-airdrop/airdrop.gno Outdated Show resolved Hide resolved
examples/gno.land/r/demo/foo20-airdrop/airdrop.gno Outdated Show resolved Hide resolved
examples/gno.land/r/demo/foo20-airdrop/airdrop.gno Outdated Show resolved Hide resolved
examples/gno.land/r/demo/foo20-airdrop/airdrop_test.gno Outdated Show resolved Hide resolved
examples/gno.land/r/demo/foo20-airdrop/airdrop_test.gno Outdated Show resolved Hide resolved
examples/gno.land/r/demo/foo20-airdrop/airdrop_test.gno Outdated Show resolved Hide resolved
examples/gno.land/r/demo/foo20-airdrop/airdrop_test.gno Outdated Show resolved Hide resolved
examples/gno.land/r/demo/foo20-airdrop/airdrop_test.gno Outdated Show resolved Hide resolved
Copy link
Member

@moul moul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just blocking since there are several changes. Let’s make an additional round of reviews.

@moul moul marked this pull request as draft August 6, 2023 23:07
@albttx
Copy link
Member Author

albttx commented Aug 9, 2023

There is tests issue once rebased with master.

There is a situation to figure out, with grc20.IGRC20, because it return a grc20.UserToken .

When user1.gno -> r/foo20-airdrop get foo20.GRC20() and then from r/foo20-airdrop exec foo20.GRC20().Transfert, std.PrevRealm isn't the realm but the user ...

Possible fix could be to update in user_token.gno to use CurrentRealm rather than PrevRealm

@moul
Copy link
Member

moul commented Aug 9, 2023

Related (and depending?) on #952

@zivkovicmilos
Copy link
Member

Hey @albttx,

What's the status of this PR?

@moul moul added this to the 🌟 main.gno.land (wanted) milestone Sep 8, 2023
@github-actions github-actions bot added the 📦 🤖 gnovm Issues or PRs gnovm related label Oct 18, 2023
@leohhhn
Copy link
Contributor

leohhhn commented Nov 28, 2024

@moul

Want to take a final look? Cannot merge without your approval.

@Gno2D2
Copy link
Collaborator

Gno2D2 commented Jan 10, 2025

🛠 PR Checks Summary

All Automated Checks passed. ✅

Manual Checks (for Reviewers):
  • IGNORE the bot requirements for this PR (force green CI check)
Read More

🤖 This bot helps streamline PR reviews by verifying automated checks and providing guidance for contributors and reviewers.

✅ Automated Checks (for Contributors):

🟢 Maintainers must be able to edit this pull request (more info)

☑️ Contributor Actions:
  1. Fix any issues flagged by automated checks.
  2. Follow the Contributor Checklist to ensure your PR is ready for review.
    • Add new tests, or document why they are unnecessary.
    • Provide clear examples/screenshots, if necessary.
    • Update documentation, if required.
    • Ensure no breaking changes, or include BREAKING CHANGE notes.
    • Link related issues/PRs, where applicable.
☑️ Reviewer Actions:
  1. Complete manual checks for the PR, including the guidelines and additional checks if applicable.
📚 Resources:
Debug
Automated Checks
Maintainers must be able to edit this pull request (more info)

If

🟢 Condition met
└── 🟢 The pull request was created from a fork (head branch repo: albttx/gno)

Then

🟢 Requirement satisfied
└── 🟢 Maintainer can modify this pull request

Manual Checks
**IGNORE** the bot requirements for this PR (force green CI check)

If

🟢 Condition met
└── 🟢 On every pull request

Can be checked by

  • Any user with comment edit permission

@albttx
Copy link
Member Author

albttx commented Jan 10, 2025

Rebased, CI green, waiting for final reviews @moul

@moul
Copy link
Member

moul commented Jan 10, 2025

Can you provide an example, perhaps in txtar format, or as a mini app in JavaScript, Go, or another language, using this from an external perspective?

@albttx
Copy link
Member Author

albttx commented Jan 11, 2025

Can you provide an example, perhaps in txtar format, or as a mini app in JavaScript, Go, or another language, using this from an external perspective?

@moul i've previously add a small js app in misc/ to explain how it's work but @leohhhn reviews asked to remove it... (97ca397 )

I will work on a small example app.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📦 🤖 gnovm Issues or PRs gnovm related 🧾 package/realm Tag used for new Realms or Packages.
Projects
Status: In Progress
Status: 🌟 Wanted for Launch
Development

Successfully merging this pull request may close these issues.

8 participants